using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using NUnit.Framework;

using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework;
using Castle.ActiveRecord.Framework.Config;

using Demo.Model;

namespace Demo.Model.Test
{
    [TestFixture]
    public class CityTestCase : AbstractModelTestCase
    {
        [Test]
        public void Creation()
        {
            State state = new State();
            state.Description = "Buenos Aires";
            state.Save();

            City city = new City();
            city.Description = "Lomas de Zamora";
            city.State = state;
            city.Save();

            Assert.IsTrue(State.FindAll().Length == 1);
            Assert.IsTrue(City.FindAll().Length == 1);
        }

        [Test]
        public void FindAllByDescription()
        {
            State state = new State();
            state.Description = "Buenos Aires";
            state.Save();

            City city = new City();
            city.Description = "Lomas del Mirador";
            city.State = state;
            city.Save();

            city = new City();
            city.Description = "Lomas de Zamora";
            city.State = state;
            city.Save();

            city = new City();
            city.Description = "Lomas del Orto";
            city.State = state;
            city.Save();

            City[] cities = City.FindAllByPropertyLike("Description", "Lomas", 2, "State.ID", state.ID);
            Assert.IsTrue(cities.Length == 2);
        }

    }
}
